package com.source.baseData.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.source.baseData.entity.PoultryCategoryParent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Joey
 * @since 2021-02-22
 */
@Repository
public interface PoultryCategoryParentMapper extends BaseMapper<PoultryCategoryParent> {

    String SELECT = "select * from poultry_category_parent pcp where pcp.isDelete = 0 ";

    @Select("select * from poultry_category_parent pcp where pcp.isDelete = 0 ")
    IPage<PoultryCategoryParent> findAllOnPagination(Page<PoultryCategoryParent> page);

    @Select("SELECT poultryParentName FROM poultry_category_parent pcp where pcp.isDelete = 0 AND pcp.poultryCategoryParentId = #{id}")
    String findNameById(String id);

    @Select(SELECT + "AND CONCAT_WS(',',poultryCategoryParentId, poultryParentName, createDate) LIKE #{s}")
    List<PoultryCategoryParent> findByKeyWord(String s);
}
